﻿using System;
using DataAccess;
using Entities;
using System.Collections.Generic;

namespace Business
{
    public class EmployeeBUS
    {
        public static Employee Get_Employee_By_ID(string userName)
        {
            EmployeeDAL Emp_DAL = new EmployeeDAL();
            return Emp_DAL.Get_Employee_By_ID(userName);
        }

        public static List<Employee> GetAll_Employee()
        {
            EmployeeDAL Emp_DAL = new EmployeeDAL();
            return Emp_DAL.GetAll_Employee();
        }

        public static List<Employee> GetList_Employee(string whereSql, string orderBy)
        {
            EmployeeDAL Emp_DAL = new EmployeeDAL();
            if (string.IsNullOrEmpty(orderBy)) orderBy = "";
            if (string.IsNullOrEmpty(whereSql)) whereSql = "";
            return Emp_DAL.GetList_Employee(whereSql, orderBy);
        }

        public List<Employee> Get_EmployeeAsPaging(string sWhere, string sOrderBy, int pageIndex, int pageSize)
        {
            EmployeeDAL Emp_DAL = new EmployeeDAL();
            if (string.IsNullOrEmpty(sWhere)) sWhere = "";
            if (string.IsNullOrEmpty(sOrderBy)) sOrderBy = "";
            return Emp_DAL.Get_EmployeeAsPaging(sWhere, sOrderBy, pageIndex, pageSize);
        }

        public static bool IsExitEmployee(string userName, string password, ref string emp_ID)
        {
            List<Employee> lst = EmployeeBUS.GetList_Employee("UserName='" + userName.Trim() + "' AND Password='" + password.Trim() + "'", "");

            if (lst == null || lst.Count == 0)
                return false;
            else
            {
                foreach (Employee temp in lst)
                {
                    emp_ID = temp.UserName;
                }
                return true;
            }
        }

        public static bool Insert_Employee(Employee temp)
        {
            EmployeeDAL Emp_DAL = new EmployeeDAL();
            return Emp_DAL.Insert_Employee(temp);
        }

        public static bool Update_Employee(Employee temp)
        {
            EmployeeDAL Emp_DAL = new EmployeeDAL();
            return Emp_DAL.Update_Employee(temp);
        }

        public static bool Delete_Employee(Employee temp)
        {
            EmployeeDAL Emp_DAL = new EmployeeDAL();
            return Emp_DAL.Delete_Employee(temp);
        }
        
    }
}
